import { deleteAnswer,getProjectAnswerList, getProjectAnswermyAnswerList2, getProjectAnswermyAskList1, UpdateMyReply } from "@/services/modules/students/projectAnswer"
import {  IProjectAnswerListItem, IProjectAnswerParams, IUpdateItem, IWenda } from "@/utils/students/projectAnswer"
import { makeAutoObservable } from "mobx"

class ProjectAnswer {
    constructor() {
        makeAutoObservable(this)
    }


    //学生问答列表数据
    ProjectAnswerList: IProjectAnswerListItem[] = []
    ProjectAnswerListLen: number = 0
    async getProjectAnswerList(params: IProjectAnswerParams) {
        let res = await getProjectAnswerList(params)
        if (res.rows) {
            this.ProjectAnswerList = res.rows
            this.ProjectAnswerListLen = res.total
        }
    }


    //问答管理  我的问题 getProjectAnswermyAskList
    ProjectAnswermyAskList1: IProjectAnswerListItem[] = []
    ProjectAnswermyAskListLen1: number = 0
    async getProjectAnswermyAskList1(params: IWenda) {
        let res = await getProjectAnswermyAskList1(params)
        if (res.rows) {
            this.ProjectAnswermyAskList1 = res.rows
            this.ProjectAnswermyAskListLen1 = res.total
        }
    }
    //问答管理  我的答案 getProjectAnswermyAskList
    ProjectAnswermyAskList2: IProjectAnswerListItem[] = []
    ProjectAnswermyAskListLen2: number = 0
    async getProjectAnswermyAnswerList2(params: IWenda) {
        let res = await getProjectAnswermyAnswerList2(params)
        console.log(res.rows, "00000")
        if (res.rows) {
            this.ProjectAnswermyAskList2 = res.rows
            this.ProjectAnswermyAskListLen2 = res.total
        }
    }
    //分页

    pageNum: number = 1
    setPAgeNum(e: number) {
        this.pageNum = e
    }

    //类型状态
    curgenre = ""
    setCurgenre(type: string) {
        this.curgenre = type
    }
    // quality: 1 只看精品
    quality = ""
    setQuality(e: boolean) {
        this.quality = e == true ? "1" : ""
    }
    // authentication:  //只看讲师
    authentication = ""
    setAuthentication(e: boolean) {
        e ? this.authentication = "1" : this.authentication = ""
    }
    //模糊搜索

    title = ""
    questionTitle = ""
    setTitle(e: string) {
        this.title = e
    }
    setQuestionTitle(title: string) {
        this.questionTitle = title
    }

    //修改编辑
    async UpdateMyReply(params: IUpdateItem) {
        let res = await UpdateMyReply(params)
        console.log(res)
    }
    //删除问题

    async deleteAnswer(params: any) {
        let res = await deleteAnswer(params)
        console.log(res)
    }
}
export default new ProjectAnswer